module MatchesHelper
  def point_spread(match,team)
    case match.bet_type
      when "total"
        if team == match.home_team
          "total over #{match.total_point}"
        else
          "total under #{match.total_point}"
        end
      else
        home_point_spread = away_point_spread = match.point_spread.to_f.abs.to_s
        if match.point_spread.to_f >= 0
          home_point_spread = "+" + home_point_spread
          away_point_spread = "-" + away_point_spread
        else
          home_point_spread = "-" + home_point_spread
          away_point_spread = "+" + away_point_spread
        end

        if team == match.home_team
          content_tag(:span, home_point_spread ,:class=>"bet-spread")
        else
          content_tag(:span, away_point_spread ,:class=>"bet-spread")
        end
    end
  end


  def match_rss_content(match)
    %Q{
        #{match.home_team.name} #{match.point_spread} vs
        #{match.away_team.name} #{- match.point_spread}
        starts in #{time_ago_in_words match.begin_at}.
        #{match.bets_count} people have taken a side
     }
  end

  def match_rss_title(match)
    "#{match.home_team.name} VS #{match.away_team.name}"
  end


end
